// editequipparamdlg.cpp : implementation file
//

#include "stdafx.h"

#include "editequipparamdlg.h"
#include "Equip.h"
#include "PropertyOwner.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// EditEquipParamDlg dialog


EditEquipParamDlg::EditEquipParamDlg(Equip* pEquip,CWnd* pParent /*=NULL*/)
	: CDialog(EditEquipParamDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(EditEquipParamDlg)
	ASSERT(pEquip);
	m_pEquip = pEquip;
	//}}AFX_DATA_INIT
}


void EditEquipParamDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(EditEquipParamDlg)
	DDX_Control(pDX, IDC_PICTURE, m_picture);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(EditEquipParamDlg, CDialog)
	//{{AFX_MSG_MAP(EditEquipParamDlg)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// EditEquipParamDlg message handlers

int EditEquipParamDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	ASSERT(m_pEquip);
	pa::PropertyOwner* pOwner = static_cast<PropertyOwner*>(m_pEquip);

	CRect size(0,0,0,0);
	this->GetClientRect(size);
	size = CRect(size.left,size.top,size.right-(size.right - size.left)/2,size.bottom - (size.bottom - size.top)/5.0);
	m_oWnd.SetWindowParam(this,size);
	m_oWnd.CreateParamWindow(*pOwner);
	m_oWnd.ShowWindow(TRUE);
	
	return 0;
}

BOOL EditEquipParamDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CRect size(0,0,0,0);
	this->GetClientRect(size);
	m_picture.SetBitmap(m_pEquip->GetImagePath());
	::SetWindowPos(m_picture,wndTop,size.right - (size.right - size.left)/2 + 10,size.top,(size.right-size.left)/2 -10,size.bottom - (size.bottom - size.top)/5.0 - size.top,SWP_DRAWFRAME);

	return TRUE;
}